home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17253 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  52 lines

  1. Path: jupiter.sun.csd.unb.ca!e5ir
  2. From: e5ir@jupiter.sun.csd.unb.ca (Paul Vermette [NiD/BiM])
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Arrays in C and c++
  5. Date: 14 Apr 1996 20:37:45 GMT
  6. Organization: University of New Brunswick, Fredericton, NB, Canada
  7. Message-ID: <4krnmp$pf8@sol.sun.csd.unb.ca>
  8. References: <4kc929$38k@hermes.acs.unt.edu>
  9. NNTP-Posting-Host: jupiter-alt3.unb.ca
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Joseph Neal Rake (jnr0001@jove.acs.unt.edu) wrote:
  13. : Is it possible to do 2 dimensional arrays in C or C++?  If so, how?
  14.  
  15. : This is probably a related question:  How does one do an array of strings 
  16. : in C or C++, since 1 string is already an array?
  17.  
  18. : Thanx for any help
  19.  
  20. well, I always use a pointer the screen when doing graphics routine which
  21. the screen is in two dimensions and I am using a 1 dimensional array..
  22.  
  23. The idea behind it is that 
  24.     screen[320][200] = screen[x][y] = screen[320*y + x]
  25.  
  26. Just apply this to two dimensional or n-dimensional array, and this way
  27. you can dynamically allocate it with the new operator which would just be
  28. like    
  29.  
  30. char * strname = new char[320*200];
  31.  
  32. well you get the idea
  33.  
  34. : --
  35. : This message was authored by Joseph Neal Rake, esquire
  36. : Look for TennisMan on IRC
  37. : Check out my home page, the pictures are working again!  
  38. : http://www.umr.edu/~jnrake
  39.  
  40. --
  41.                    '''
  42.                   (o o)
  43.   .---------oOOO---(_)------------------.
  44.   |       Paul Vermette [NiD/BiM]       |
  45.   |             e5ir@unb.ca             |
  46.   |    B O D i E S  i N  M o T i O N    |
  47.   `----------------------oOOO-----------'
  48.                  |__|__|
  49.                   || ||
  50.                  ooO Ooo
  51.  
  52.